package com.d3.sx_eprotection.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.d3.sx_eprotection.entity.SupervisorMesg;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface SupervisorMesgMapper extends BaseMapper<SupervisorMesg> {
    @Select("select * from supervisor_mesg where supervisor_phone = #{number}")
    List<SupervisorMesg> findAll(String number);

    @Select("select * from supervisor_mesg where grider_id = #{code}")
    @Results({
            @Result(column = "supervisor_phone",property = "supervisor_phone"),
            @Result(column = "grider_id",property = "grider_id")
    })
    List<SupervisorMesg> findBelong(String code);

    @Select("select * from supervisor_mesg where id = #{id}")
    @Results({
            @Result(column = "supervisor_phone",property = "supervisor_phone"),
            @Result(column = "grider_id",property = "grider_id")
    })
    List<SupervisorMesg> findone(int id);

    @Results({
            @Result(column = "userPhone",property = "userPhone"),
            @Result(column = "userPhone",property = "supervisor",one = @One(select = "com.d3.sx_eprotection.mapper.SupervisorMapper.selectById"))
    })
    @Select("select * from supervisormesg where belongTo is  null")
    List<SupervisorMesg> getShowList();


    @Results({
            @Result(column = "userPhone",property = "userPhone"),
            @Result(column = "userPhone",property = "supervisor",one = @One(select = "com.d3.sx_eprotection.mapper.SupervisorMapper.selectById"))
    })

    @Update("update supervisor_mesg set grider_id = #{griderCode} and status = 1 where id = #{id}")
    Boolean updateGrider(int id,String griderCode);
    @Update("update supervisor_mesg set status = 3 where id = #{id}")
    Boolean updateStatus(int id);
    @Select("select * from supervisor_mesg where status = 3")
    List<SupervisorMesg> getFinsh();
}
